<?php

namespace App\EventListener;

use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationFailureEvent;

class AuthenticationFailureListener {

    /**
     * @param AuthenticationFailureEvent $event
     */
    public function onAuthenticationFailureResponse (AuthenticationFailureEvent $event) {
        $response = json_failure('Bad credentials, please verify that your username/password are correctly set', 401);
        $event->setResponse($response);
        $event->getResponse()->setStatusCode(401);
    }
}